Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(manager-react-components): useNotifications prevent early clears #14234

Closed
wants to merge 1 commit into from

Conversation

tristanwagner
Copy link
Contributor

@tristanwagner tristanwagner commented Nov 22, 2024

this is a cherry pick of this commit on mrc v1 maintenance branch

Question Answer
Branch? develop
Bug fix? yes
New feature? no
Breaking change? no
Tickets Fix #...
License BSD 3-Clause
  • Try to keep pull requests small so they can be easily reviewed.
  • Commits are signed-off
  • Only FR translations have been updated
  • Branch is up-to-date with target branch
  • Lint has passed locally
  • Standalone app was ran and tested locally
  • Ticket reference is mentioned in linked commits (internal only)
  • Breaking change is mentioned in relevant commits

Description

Related

@tristanwagner tristanwagner self-assigned this Nov 22, 2024
@github-actions github-actions bot added the bug Something isn't working label Nov 22, 2024
@tristanwagner tristanwagner marked this pull request as ready for review November 22, 2024 11:43
@tristanwagner tristanwagner requested review from a team as code owners November 22, 2024 11:43
Comment on lines 52 to 59
await new Promise((resolve) => setTimeout(resolve, 2000));

render(<ClearNotifications />);
container = render(<Notifications />).container;

await waitFor(() => {
expect(container.children.length).toBe(0);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better mock Date.

  • It's a unit test we don't test Data.now() method
  • This allow to do the test faster

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enhanced the tests according to your suggestions

clearNotifications: () =>
set((state) => ({
notifications: state.notifications.filter(
(notification) => Date.now() - notification.creationTimestamp < 1000,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(notification) => Date.now() - notification.creationTimestamp < 1000,
(notification) => Date.now() - notification.creationTimestamp < DEFAULT_MINIMUN_LIFETIME,

Optionnal suggestion : Possible to add constant for default minimum lifetime and maybe add parameters if we want more or less on the future ?

Copy link
Contributor Author

@tristanwagner tristanwagner Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me the whole api should be reworked, for example we should be able to set "clearAfterRead" per notification instead of for all of them, but I think it should be another subject, right now I'm just trying to be up to date with MRC v1 on this issue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI we opened this PR to sync the changes we introduced in MRC 1.x : #14170

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok wasn't aware of that I'll just close this one then

Copy link

sonarcloud bot commented Nov 22, 2024

@tristanwagner
Copy link
Contributor Author

should be handled by #14170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants